package com.wd.cloud.applet.config;

import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;

public class MybatisPlusPageConfig {
    public MybatisPlusPageConfig() {
    }

    public static <T, U> CustomListResultConfig<T> toPageResult(IPage<U> page, Class<T> modelClass) {
        CustomListResultConfig<T> result = new CustomListResultConfig();
        result.setPage(page.getCurrent());
        result.setLimit(page.getSize());
        result.setPageCount(page.getPages());
        result.setTotal(page.getTotal());
        List<T> list = ModelMapperConfig.mapList(page.getRecords(), modelClass);
        result.setList(list);
        return result;
    }
}
